package com.liangsong.designpattern.factory;

import com.liangsong.designpattern.factory.common.Baozi;
import com.liangsong.designpattern.factory.common.PorkBaozi;
import com.liangsong.designpattern.factory.common.SuancaiBaozi;

/**
 * @author liangsong
 * @version v1.0 2025/1/9
 * 包子肯定有不同的馅：酸菜、豆沙、猪肉，那么他的材料、售价等方式也不同
 * *我们可以直接在上述代码中，添加根据包子的不同种类生成不同的对象。
 * */
public class TraditionalFactory {
    public void createBaozi(String type){
        Baozi baozi = switch (type) {
            case "suancai" -> new SuancaiBaozi();
            case "pork" -> new PorkBaozi();
            default -> throw new IllegalArgumentException("没有这种包子");
        };
        baozi.prepare();
        baozi.make();
        baozi.braise();
    }
}
